package com.arturjaneczko.view.impl.clipboard._component;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.SwingConstants;

import com.arturjaneczko.model.impl.EClipboardDataType;

@SuppressWarnings("serial")
public class ClipboardObjectTypeView extends JPanel {

	private JLabel label;

	public ClipboardObjectTypeView() {
		super();
		
		this.addMouseListener(new MouseAdapter() {
			@Override
			public void mousePressed(MouseEvent e) {
				System.out.println("type panel pressed...");
			}
		});
		
		label = new JLabel();
		label.setHorizontalAlignment(SwingConstants.CENTER);
		label.setOpaque(true);
		label.setText("");
		label.setBackground(Color.NOTE.getColor());
		label.setForeground(Color.TEXT.getColor());
		label.setPreferredSize(new Dimension(50, 20));

		FlowLayout fl = (FlowLayout) this.getLayout();
		fl.setHgap(0);
		fl.setVgap(0);
		this.setLayout(fl);
		this.add(label);
	}

	public void update(EClipboardDataType clipboardDataType,
			java.awt.Color color) {
		if (clipboardDataType == null)
			System.out.println("WTF!");
		else {
			label.setText(clipboardDataType.getShortcut());
			label.setBackground(color);			
		}
	}
}
